'''
3 4
yny
nyy
nyn
yyn
'''

x, y = map(int, input().split())
for i in range(y):
    s = input().replace('y', '0').replace('n', '1')
    print(int(s, 2) + 1, end='')
    if i != y - 1:
        print()
